﻿//////////////////////////////////////////////////////////////////////////////
//
// Copyright © 1998-2024 Glodon Company Limited.
//
// Licensed under the MIT License
//
// Permission is hereby granted, free of charge, to any person obtaining a
// copy of this software and associated documentation files (the “Software”),
// to deal in the Software without restriction, including without limitation
// the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
// sell copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
//////////////////////////////////////////////////////////////////////////////
#pragma once
#include "Vector3d.h"

#include "Box3d.h"

namespace gcmp
{
    class IGraphicsBRepEdge;
    class IEdge;
    class ICurve3d;
    class PreviewHelper
    {
        //屏幕像素(未来也许可通过界面设置)
        //实际的方框会比原来【对象集】四周大一点点
        enum { HELPER_RECT_GAP = 5 };

    public:

        //根据指定的元素，在视图中创建临时对象
        PreviewHelper(const IUiView* pUiView, const std::vector<IElement*> &elemnts);

        ~PreviewHelper();

        //生成新的临时对象
        void ResetPreview(const IUiView* pUiView, const std::vector<IElement*> &elements = std::vector<IElement* >());




    public:
        //移动生成并移动预览对象
        OwnerPtr<IGraphicsElementShape> GetMoveTempGRep(const Vector3d& lbOfSet);
    protected:
        //从Element 中获得GraphicNode
        void GetGraphicNodeFromElement(IElement * pElement, IModelView* pModelView, IDocument* pDoc);

        //对各种GraphicsNode 取包围盒
        void GetBox(const IGraphicsNode * pgn, Box3d & box);

        //从Element 中获得线，并绘制包围盒的12条边
        void AddBoxLines(IDocument* pDoc, Box3d &totalbox, std::vector<OwnerPtr<IGraphicsNode>> & preViewObjects);

        //从ISelection中获得 Element
        void GetSelectedElements(std::vector<IElement*> & operationElements);

        //遍历子GraphicNode，获取可复制的GraphicNode
        void GetClonableSubGraphicNode(const IGraphicsNode * pGraphicNode);

    private:
        //当前视图
        WeakPtr<const IUiView> m_wpUiView;
        
        
        std::vector<OwnerPtr<IGraphicsNode>> m_preViewObjects;
    };
}